package com.game2048;

import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

/**
 * Created by ${张英杰} on 2017/2/25.
 */

public class Card extends FrameLayout {
    private int num = 0;
    private TextView label;

    public Card(Context context) {
        super(context);
        label = new TextView(context);
        label.setTextSize(32);
        label.setBackgroundColor(0x33ffffff);
        label.setGravity(Gravity.CENTER);
        LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, -1);
        lp.setMargins(10,10,10,10);
        addView(label, lp);
        setNum(0);
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
        if (num<=0){
            label.setText("");
        }else {
            label.setText(num + "");
        }
    }

    //是否可以折叠
    public boolean equals(Card obj) {
        return getNum()==obj.getNum();
    }
}
